/*
 * 文件名： MBeanUtils.java
 *
 * 创建日期： 2017年3月7日
 *
 * Copyright(C) 2017, by <a href="mailto:liws@xingyuanauto.com">liws</a>.
 *
 * 原始作者: liws
 *
 */
package com.moli.iov.gateway.util;

import java.lang.management.ManagementFactory;

import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 *
 * @author <a href="mailto:liws@xingyuanauto.com">liws</a>
 *
 * @version $Revision$
 *
 * @since 2017年3月7日
 */
public class MBeanUtils {

	private static final Logger logger = LoggerFactory.getLogger(MBeanUtils.class);

	static final  MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
	/**
	 * 注册MBean
	 *
	 * @param obj
	 * @param objName
	 */
	public static void registerMBean(Object obj,ObjectName objName){
		try {
			mBeanServer.registerMBean(obj, objName);
		}
		catch (InstanceAlreadyExistsException e) {
			logger.error(e.getMessage(),e);
		}
		catch (MBeanRegistrationException e) {
			logger.error(e.getMessage(),e);
		}
		catch (NotCompliantMBeanException e) {
			logger.error(e.getMessage(),e);
		}
	}
}
